﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using XcoAppSpaces.Serialization.Json;

namespace test.XcoAppSpaces.Serialization.Json
{
	[TestFixture]
	public class testSerializableCheck
	{
		public class SerializableClass { }
		public interface SerializableInterface { }
		class NonPublicClass { }
		public class ClassWithNoEmptyConstructor { public ClassWithNoEmptyConstructor(string notempty) { } }
		public class ClassWithNoPublicConstructor { protected ClassWithNoPublicConstructor(string notempty) { } }

		[Test]
		public void CanBeSerialized()
		{
			string errorInfo;
			Assert.IsTrue(SerializableCheck.CanTypeBeSerialized(typeof(int), out errorInfo));
			Assert.IsTrue(SerializableCheck.CanTypeBeSerialized(typeof(string), out errorInfo));
			Assert.IsTrue(SerializableCheck.CanTypeBeSerialized(typeof(DateTime), out errorInfo));
			Assert.IsTrue(SerializableCheck.CanTypeBeSerialized(typeof(SerializableClass), out errorInfo));
			Assert.IsTrue(SerializableCheck.CanTypeBeSerialized(typeof(SerializableInterface), out errorInfo));
			Assert.IsFalse(SerializableCheck.CanTypeBeSerialized(typeof(NonPublicClass), out errorInfo));
			Assert.IsFalse(SerializableCheck.CanTypeBeSerialized(typeof(ClassWithNoEmptyConstructor), out errorInfo));
			Assert.IsFalse(SerializableCheck.CanTypeBeSerialized(typeof(ClassWithNoPublicConstructor), out errorInfo));
		}
	}
}
